<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div class='wrapper'>
        <button class='like-btn'>
            <span class="like-text">👍</span>
        </button>
    </div>
    <script>
        /*
            1、一个简单的点赞功能
            comment:以点赞按钮为例，原生js操作点赞按钮
            todo: 如何复用点赞按钮？？？
        */
        const button = document.querySelector('.like-btn')
        const buttonText = button.querySelector('.like-text')
        let isLiked = false
        button.addEventListener('click', () => {
            isLiked = !isLiked
            if (isLiked) {
                buttonText.innerHTML = '取消'
            } else {
                buttonText.innerHTML = '点赞'
            }
        }, false)
    </script>
</body>

</html>